{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post" enctype="multipart/form-data" onsubmit="return false;">
    
                 
             <div class="layui-form-item">
                   <label class="layui-form-label">头像图片</label>
                 <div class="layui-input-inline">
                        <div class="profile-avatar-container">
                  <img id="image" class="profile-user-img img-responsive" src="{$img.url|default='/static/libs/images/no_image.jpg'}" alt="">
            <span class="layui-upload-list">
                   <div class="profile-avatar-text">{:__('Click Edit')}</div>
               <button type="button" id="ajax-admin-avatar"><i class="fa fa-upload"></i>{:__('Edit')}</button>
            </span>
            <span class="layui-upload-list" style="padding-left: 20px;"></span>
                       </div>
                   </div>
            <input type="hidden" name="filesize" id="filesize" value="">
            <input type="hidden" name="mine" id="mine" value="">
            <input type="hidden" name="image" value="">
           </div>
                                    <!-----隐藏id-------->
                <input type="hidden" name="group" id="group" value="{$admin.group_id|default=''}" >
                                            <!-----隐藏id------->

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Permission group')}</label>
         <div class="layui-input-inline" style="width:170px;">
                <select class="layui-input" name="group_id" id="group_id" lay-verify="required" lay-search="">
                    <option value="0">{:__('Please select')}</option>
                    {foreach $group as $vo}
                   <option value="{$vo.id}" {if condition="isset($data.group_id) and $data.group_id == $vo.id"}selected="selected"{/if}>{$vo.group_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('First name')}</label>
            <div class="layui-input-block">
                <input type="text" placeholder="{:__('enter one user name')}" name="username" value="{$data.username|default=''}" style="width: 95%" id="username" lay-verify="required"
                       lay-reqtext="{:__('User name is required. How can it be empty')}" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Mailbox')}</label>
            <div class="layui-input-block">
                <input type="text" placeholder="{:__('Please input email')}" id="email" name="email" value="{$data.email|default=''}" style="width: 95%" lay-verify="email"autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('password')}</label>
            <div class="layui-input-block">
                <input type="password" name="password" id="password" value="" style="width: 95%" placeholder="{:__('Please input a password')}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                    <button class="layui-btn layui-btn-sm" lay-filter="save" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger close">关闭</button>
            </div>
        </div>
    </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
layui.use(['upload', 'element', 'table', 'form', 'layer', 'jquery'], function () {

             var upload = layui.upload;
             var form = layui.form;
             var $    = layui.jquery;        
             form.render();
   //普通图片上传
      var uploadInst = upload.render({
    elem: '#ajax-admin-avatar',
            exts: 'jpg|png|jpeg|gif|svg',
            size: 2048,
    url: "{:url('upload/uploadImage',['model'=>'2'])}", //改成您自己的上传接口
    done: function (result) {
        //上传完毕回调
        if (result.code === 1) {
            $('#image').attr('src', result.url);
            //this.item.prev('input').val(result.url);
            $('input[name="image"]').val(result.url);
            $('input[name="filesize"]').val(result.filesize);
            $('input[name="mine"]').val(result.mine);
            layer.msg(result.msg, {icon: 1});
        } else {
            layer.msg(result.msg, {icon: 2});
        }
    }
        });
});
</script>
{/block}

